home *** CD-ROM | disk | FTP | other *** search
/ Game Programming in C++ - Start to Finish / GameProgrammingS.iso / developer_install / CEGUISDK-0.4.1-VC6-STLport.exe / {app} / Samples / common / include / CEGuiOgreBaseApplication.h < prev    next >
C/C++ Source or Header  |  2005-11-26  |  4KB  |  131 lines

  1. /************************************************************************
  2.     filename:   CEGuiOgreBaseApplication.h
  3.     created:    9/3/2004
  4.     author:     Paul D Turner
  5. *************************************************************************/
  6. /*************************************************************************
  7.     Crazy Eddie's GUI System (http://www.cegui.org.uk)
  8.     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
  9.  
  10.     This library is free software; you can redistribute it and/or
  11.     modify it under the terms of the GNU Lesser General Public
  12.     License as published by the Free Software Foundation; either
  13.     version 2.1 of the License, or (at your option) any later version.
  14.  
  15.     This library is distributed in the hope that it will be useful,
  16.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  18.     Lesser General Public License for more details.
  19.  
  20.     You should have received a copy of the GNU Lesser General Public
  21.     License along with this library; if not, write to the Free Software
  22.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  23. *************************************************************************/
  24. #ifndef _CEGuiOgreBaseApplication_h_
  25. #define _CEGuiOgreBaseApplication_h_
  26.  
  27. #include "CEGuiBaseApplication.h"
  28. #include "CEGUI.h"
  29.  
  30. #include "renderers/OgreGUIRenderer/OgreCEGUIRenderer.h"
  31. #include <Ogre.h>
  32. #include <OgreEventListeners.h>
  33.  
  34. #if defined(_WIN32)
  35. #  if defined(_DEBUG)
  36. #      pragma comment(lib, "OgreGUIRenderer_d.lib")
  37. #      pragma comment(lib, "OgreMain_d.lib")
  38. #  else
  39. #      pragma comment(lib, "OgreGUIRenderer.lib")
  40. #      pragma comment(lib, "OgreMain.lib")
  41. #  endif
  42. #endif
  43.  
  44. // Frame listener forward ref (see class below)
  45. class CEGuiDemoFrameListener;
  46.  
  47.  
  48. class CEGuiOgreBaseApplication : public CEGuiBaseApplication
  49. {
  50. public:
  51.     /*!
  52.     \brief
  53.         Constructor.
  54.     */
  55.     CEGuiOgreBaseApplication();
  56.  
  57.  
  58.     /*!
  59.     \brief
  60.         Destructor.
  61.     */
  62.     virtual ~CEGuiOgreBaseApplication();
  63.  
  64.  
  65.     // Implementation of base class abstract methods.
  66.     bool execute(CEGuiSample* sampleApp);
  67.     void cleanup();
  68.  
  69. protected:
  70.     void initialiseResources(void);
  71.  
  72.     /*************************************************************************
  73.         Data Fields
  74.     *************************************************************************/
  75.     Ogre::Root* d_ogreRoot;
  76.     Ogre::Camera* d_camera;
  77.     Ogre::RenderWindow* d_window;
  78.     CEGUI::OgreCEGUIRenderer* d_renderer;
  79.     bool d_initialised;
  80.  
  81.     CEGuiDemoFrameListener* d_frameListener;
  82. };
  83.  
  84.  
  85. /*!
  86. \brief
  87.     Ogre FrameListener class where we deal with input processing and the like.
  88. */
  89. class CEGuiDemoFrameListener: public Ogre::FrameListener, public Ogre::KeyListener, Ogre::MouseMotionListener, Ogre::MouseListener
  90. {
  91. public:
  92.     // Construction and Destruction
  93.     CEGuiDemoFrameListener(CEGuiBaseApplication* baseApp, Ogre::RenderWindow* win, Ogre::Camera* cam, bool useBufferedInputKeys = false, bool useBufferedInputMouse = false);
  94.     ~CEGuiDemoFrameListener();
  95.  
  96.     // Processing to be done at start and end of each frame.
  97.     bool frameStarted(const Ogre::FrameEvent& evt);
  98.     bool frameEnded(const Ogre::FrameEvent& evt);
  99.  
  100.     // Raw input handlers that we care about
  101.     void mouseMoved(Ogre::MouseEvent *e);
  102.     void mouseDragged(Ogre::MouseEvent *e);
  103.     void keyPressed(Ogre::KeyEvent *e);
  104.     void keyReleased(Ogre::KeyEvent *e);
  105.     void mousePressed(Ogre::MouseEvent *e);
  106.     void mouseReleased(Ogre::MouseEvent *e);
  107.  
  108.     // Raw input handlers that we do not care about
  109.     void keyClicked(Ogre::KeyEvent *e);
  110.     void mouseClicked(Ogre::MouseEvent *e);
  111.     void mouseEntered(Ogre::MouseEvent *e);
  112.     void mouseExited(Ogre::MouseEvent *e);
  113.  
  114. protected:
  115.     // convert an Ogre mouse button into a CEGUI mouse button
  116.     CEGUI::MouseButton convertOgreButtonToCegui(int ogre_button_id);
  117.  
  118.     /*************************************************************************
  119.         Data Fields
  120.     *************************************************************************/
  121.     Ogre::Overlay* d_statsOverlay;
  122.     Ogre::EventProcessor* d_eventProcessor;
  123.  
  124.     Ogre::Camera* d_camera;
  125.     Ogre::RenderWindow* d_window;
  126.     bool d_quit;
  127.     CEGuiBaseApplication* d_baseApp;
  128. };
  129.  
  130. #endif  // end of guard _CEGuiOgreBaseApplication_h_
  131.